// index.js
// 获取应用实例
import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
import {
  get_show
} from "../../api/shool/get_score.js";
const app = getApp()
Page({
  data: {
    show: false,
    type_1: null,
    list: [],
    token: '',
    type_2: null,
  text:"暂无考试信息(●'◡'●)",
  type_3:[{
    name: '通选&跨选',
    key: 0
  },
  {
    name: '期末-自',
    key: 136
  },
  {
    name: '期末-统',
    key: 137
  }
],
    exam_arrangement: [
      
      {
        "number": "",
        "name": "",
        "type": "",
        "time": "",
        "anpai": "",
        "didian": "",
        "zw": "",
        "bz": ""
    }
  ],
    xq: [{
        xn: '2019-2020',
        xq: [{
            type: '第一学期',
            id: 162
          },
          {
            type: '第二学期',
            id: 182
          },
        ],

      },
      {
        xn: '2020-2021',
        xq: [{
            type: '第一学期',
            id: 202
          },
          {
            type: '第二学期',
            id: 222
          },
        ],

      },
      {
        xn: '2021-2022',
        xq: [{
            type: '第一学期',
            id: 223
          },
          {
            type: '第二学期',
            id: 242
          },
        ],

      },
      {
        xn: '2022-2023',
        xq: [{
            type: '第一学期',
            id: 262
          },
          {
            type: '第二学期',
            id: 262
          },
        ],

      },
    ],
    value: null,

    xq_type: [
        "上学年",
        "下学年"
    ],

  },

  bindChange(e){
 console.log(e.detail.value)
 this.data.value={
   id:this.data.xq[i].xq[i].x
 }
  },
  //获取考试安排
  getanapi(){
    kaoshi_anpai().then(res=>{
      this.setData({
        exam_arrangement:res.data.exam_arrangement
      })
    })
  },


  // 事件处理函数
  onChange(event) {
    const {
      picker,
      value,
      index
    } = event.detail;

  },
  showPopup() {
    this.setData({
      show: true
    });
  },

  onClose() {
    this.setData({
      show: false
    });
  },
  //确定
  queding(){
      console.log('确定')

  },
 quxiao(){
  this.setData({
    show: false
  });
      
  },

  

  //删除
  test(e) {


    Dialog.confirm({
        title: '删除该请假',
        message: '确定删除嘛？',
      })
      .then(() => {
        //获取缓存
        this.data.list = wx.getStorageSync('arr') || [];
        //删除

        this.data.list.splice(e.currentTarget.dataset.id, 1);
        //重新存入
        wx.setStorageSync('arr', this.data.list)
        this.setData({
          list: this.data.list
        })
      })
      .catch(() => {
        // on cancel
      })
  },


  //添加
  add() {
    
    wx.navigateTo({
      url: '/pages/seeting/seeting',
    })
  },

  //统计使用数量




  tiao(e) {
    //跳转

    //转字符串
    var str = JSON.stringify(e.currentTarget.dataset.info)

    wx.navigateTo({
      url: '/pages/log/log?value=' + str,

    })
  },

  async onLoad() {

   
    //防止用户截屏
    // wx.onUserCaptureScreen(function (res) {
    //   that.setData({
    //     type_1:'false'
    //   })
    // })
    // wx.setScreenBrightness({
    //   value: 0.5,
    //   success: (res) => {
       
        
    //   }
    // })

    await get_show().then(res => {

      if (res.data.password == app.getVersion()) {
        this.data.type_1 = res.data.stuNumber
     
      }else{
        this.data.type_1 = 'false'
      }
      this.data.type_2 = res.data.gender

    })
    this.setData({
      type_1: this.data.type_1,
      type_2: this.data.type_2
    })
    // this.get_num()
    if (wx.getUserProfile) {
      this.setData({
        canIUseGetUserProfile: true
      })
    }
  },

  onShow() {
    this.data.list = wx.getStorageSync('arr');
    this.setData({
      list: this.data.list
    })
  },
  onUnload(){
    console.log('退出')
   
  }

  

})